package com.foreveross.framework.example.tags;

import com.foreveross.framework.example.tags.converter.CityToStringConverter;
import com.foreveross.framework.example.tags.converter.StringToCityConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebConfiguration {

  @Bean
  public WebMvcConfigurer webMvcConfigurer() {
    return new WebMvcConfigurer();
  }

  private class WebMvcConfigurer extends WebMvcConfigurerAdapter {

    @Override
    public void addFormatters(FormatterRegistry registry) {
      super.addFormatters(registry);

      registry.addConverter(new StringToCityConverter());
      registry.addConverter(new CityToStringConverter());
    }

  }

}
